package com.demo.easyexcel;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentFontStyle;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.alibaba.excel.converters.biginteger.BigIntegerNumberConverter;
import com.alibaba.excel.converters.date.DateStringConverter;
import com.alibaba.excel.converters.integer.IntegerNumberConverter;
import com.alibaba.excel.converters.string.StringStringConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigInteger;
import java.util.Date;

/**
 * @author wangfengchen
 */
@Data
@ColumnWidth(12)
@HeadRowHeight(18)
@ContentRowHeight(16)
@HeadFontStyle(fontHeightInPoints = 14)
@ContentFontStyle(fontHeightInPoints = 12, fontName = "宋体")
@ContentStyle(dataFormat = 49)
public class User {

  @ColumnWidth(18)
  @ExcelProperty(value = "姓名", converter = StringStringConverter.class)
  private String username;
  @ColumnWidth(18)
  @ExcelProperty(value = "年龄", converter = IntegerNumberConverter.class)
  private Integer age;
  @ColumnWidth(18)
  @ExcelProperty(value = "数量", converter = BigIntegerNumberConverter.class)
  private BigInteger number = BigInteger.ZERO;
  @ColumnWidth(16)
  @DateTimeFormat("yyyy-MM-dd")
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  @ExcelProperty(value = "日期", converter = DateStringConverter.class)
  private Date date;
}
